package j2metris.pieces;

import j2metris.Coordinate;
import j2metris.game.Game;
import j2metris.ControllablePiece;
import javax.microedition.lcdui.Image;

class I extends StandardPieceThatIsNotO
{
    public I()
    {
        super();
    }
    public I(int rotationState)
    {
        super(rotationState);
    }

    private static final Coordinate[][] rotationStates =
    {
        {
            new Coordinate(0, 1),
                    new Coordinate(1, 1),
                    new Coordinate(2, 1),
                    new Coordinate(3, 1)
        },
        {
            new Coordinate(2, 0),
                    new Coordinate(2, 1),
                    new Coordinate(2, 2),
                    new Coordinate(2, 3)
        },
        {
            new Coordinate(0, 2),
                    new Coordinate(1, 2),
                    new Coordinate(2, 2),
                    new Coordinate(3, 2)
        },
        {
            new Coordinate(1, 0),
                    new Coordinate(1, 1),
                    new Coordinate(1, 2),
                    new Coordinate(1, 3)
        }
    };

    public Coordinate[][] getRotationStates()
    {
        Coordinate[][] copy = new Coordinate[4][4];
        for(int i = 0; i < 4; ++i)
        {
            for(int ii = 0; ii < 4; ++ii)
            {
                copy[i][ii] = rotationStates[i][ii];
            }
        }
        return copy;
    }

    public ControllablePiece clone()
    {
        return new I(rotationStateList.getCurrentPosition());
    }

    private static final int[] arbg =
            new int[Game.getInstance().getUnitWidth() * Game.getInstance().getUnitHeight()];
    static
    {
        for(int i = 0; i < arbg.length; ++i)
        {
            arbg[i] = 0xFF00FFFF;
        }
    }
    private static final Image image = Image.createRGBImage(
            arbg,
            Game.getInstance().getUnitWidth(),
            Game.getInstance().getUnitHeight(),
            false);
    public Image getUnitImage()
    {
        return image;
    }

    public String toString()
    {
        return "I";
    }
}
